// pages/oneself/compensation/vip.js
const app = getApp()
const connector = require('../../../utils/connector.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bar_Height: wx.getSystemInfoSync().statusBarHeight + 45,
    array:[
      {id:1,name:"科一开始生效（未考科一）"},
      {id:2,name:"科二开始生效（已考科一，未考科二）"},
      {id:3,name:"科三开始生效（已考科二，未考科三）"},
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    vipUserDetail(this)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
    var that = this
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新

  },
})
function vipUserDetail(that){
  connector.getFunc(connector.connector().vipUserDetail, '', "get", app.tokens, function (res) {
    console.log(res)
    if (res.statusCode == 200) {
      console.log(res.data.result)
      let obj = res.data.result
      if(obj.user_type == 1){
        obj.types = "科一开始生效（未考科一）"
      }
      if(obj.user_type == 2){
        obj.types = "科一开始生效（未考科一）"
      }
      if(obj.user_type == 3){
        obj.types = "科三开始生效（已考科二，未考科三）"
      }
      that.setData({
        user:obj
      })
    }else{
      connector.showToasts(res.errMsg)
    }
  }, function (res) {
    connector.showToasts("内部错误")
  })
}
